attachEvent
Defines the method to add an event listener, a function that will be called whenever the specified event is delivered to the target. The list of all the available events can be found {@link /plugin/events here}.
Syntax
expression.attachEvent(id, action);
expression
- A variable that represents a Plugin class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
id | Required | string | The event name. | |
action | Required | function | The event listener. |
Returns
This method doesn't return any data.
Example
window.Asc.plugin.attachEvent("onContextMenuShow", function(options) {
if (!options) return;
if (options.type === "Selection" || options.type === "Target")
this.executeMethod("AddContextMenuItem", [getContextMenuItems()]);
});